<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>#Persistent</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#Persistent</h1>

<p>Keeps a script permanently running (that is, until the user closes it or <a href="ExitApp.htm">ExitApp</a> is encountered).</p>

<pre class="Syntax">#Persistent</pre>
<p>If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes. This is useful in cases where a script contains <a href="SetTimer.htm">timers</a> and/or <a href="Menu.htm">custom menu items</a> but not <a href="../Hotkeys.htm">hotkeys</a>, <a href="../Hotstrings.htm">hotstrings</a>, or any use of <a href="OnMessage.htm">OnMessage()</a> or <a href="Gui.htm">Gui</a>.</p>
<p>If this directive is added to an existing script, you might want to change some or all occurrences of <a href="Exit.htm">Exit</a> to be <a href="ExitApp.htm">ExitApp</a>. This is because <a href="Exit.htm">Exit</a> will not terminate a persistent script; it  terminates only the <a href="../misc/Threads.htm">current thread</a>.</p>
<p>In v1.0.16+, this directive also makes a script single-instance. To override this or change the way single-instance behaves, see <a href="_SingleInstance.htm">#SingleInstance</a>.</p>
<h3>Related</h3>
<p><a href="_SingleInstance.htm">#SingleInstance</a>, <a href="SetTimer.htm">SetTimer</a>, <a href="Menu.htm">Menu</a>, <a href="Exit.htm">Exit</a>, <a href="ExitApp.htm">ExitApp</a></p>
<h3>Example</h3>
<pre class="NoIndent">#Persistent</pre>

</body>
</html>
